package io.gitee.xyuesheng.day03;

public class Student {
    public static int id;

    private String name;
    private String sno;

    // 实例变量、成员变量
    private String password;
    private String phone;

    public int age;

    private char gender = '女';

    // 初始化对象的属性

    // 对象创建的时候，构造函数被自动调用
    public Student() {
        System.out.println("无参构造器被调用。。。");
        password = "123456";
    }

    public Student(String name) {
        this(name, null);

        System.out.println("第一个有参构造器被调用。。。");
    }

    public Student(String name, String sno) {
        if (name.length() == 0) {
            throw new RuntimeException("名字不合法！");
        } else {
            this.name = name;
        }
        this.sno = sno;
    }

    // 修改密码
    public void changePassword(String password) {
        this.password = password;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String toString() {
        return "姓名：" + this.name + " 学号："
                + this.sno + " 密码：" + password + " 电话：" + phone
                + " 年龄：" + this.age;
    }
}
